define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'resources/tagtype/index',
                    add_url: 'resources/tagtype/add',
                    edit_url: 'resources/tagtype/edit',
                    del_url: 'resources/tagtype/del',
                    multi_url: 'resources/tagtype/multi',
                    table: 'region',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('ID')},
                        {field: 'name', title: __('标签类型'), operate: 'LIKE', placeholder: __('模糊查询')},
                        {field: 'flag', title: __('标识'), operate: 'LIKE', placeholder: __('模糊查询')},
                        // {field: 'tag', title: __('Tag'),operate:'LIKE',placeholder: __('模糊查询')},
                        // {field: 'content', title: __('Content'),operate:'LIKE',placeholder: __('模糊查询')},
                        {
                            field: 'createtime',
                            title: __('创建时间'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'updatetime',
                            title: __('更新时间'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            formatter: Table.api.formatter.datetime
                        },
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
                            formatter: function (value, row, index) {
                                if (row.id == 1||row.id == 2||row.id == 3||row.id == 4||row.id == 5||row.id == 6) {
                                    return '';
                                }
                                return Table.api.formatter.operate.call(this, value, row, index);
                            }}
                    ]
                ]
            });


            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});